﻿#pragma once

#include "OCMain/ZipUtil.h"
#include "OCGIS/TiffVolume.h"

using namespace OCPP;

StringVector findFiles(String path)
{
	StringVector result;

	StringVector sv = FileUtil::findFiles(U2A(path));
	for (auto file : sv)
	{
		StringVector sv1 = StringUtil::split(file,"_");
		if (sv1.size() == 6 && sv1[4] == "0")
		{
			result.push_back(file);
		}
	}

	return result;
}

void testTiff()
{
	TiffVolume vol;

	StringMap globalOptions;
	globalOptions[VolumeOptions::Config::NameWriter] = VolumeOptions::Config::ValueD3Writer;
	globalOptions[VolumeOptions::Config::NameGZipCompress] = "yes";
	globalOptions[VolumeOptions::Config::NameOutputPath] = "E:/test";
	globalOptions[VolumeOptions::Config::NameMakeDirForFile] = "yes";
	//globalOptions[VolumeOptions::Config::NameClipRange] = "112 21 114 23";
	globalOptions[VolumeOptions::Config::NameEncodeRange] = VolumeEncoder::EncodeRangeToString(VolumeEncoder::EncodeRangeDBZ);


	//String path = "I:\\Project\\2023\\风云\\Radar2Cog_results";
	//String fileName = "Z_RADA_C_BABJ_20230801050116_P_DOR_ACHN_CAP_20230801_045400_{s}.tif";

	//String path = "I:\\Project\\2024\\风云\\Radar2Cog_results0103\\130001";
	//String fileName = "Z_RADA_C_BABJ_20230901130541_P_DOR_Z9755_CAP_20230901_130001_{s}_4326.tiff";
	//vol.read(path, fileName, options);
#if 0
	String path = "I:/Project/2024/风云";
	StringVector sv = findFiles(joinPath(path,"WIU"));
	for (auto file : sv)
	{
		//globalOptions[VolumeOptions::Config::NameEncodeRange] = VolumeEncoder::EncodeRangeToString(VolumeEncoder::EncodeRangeWind);
		//globalOptions[VolumeOptions::Config::NameClipRange] = "118.1371 16.6092 129.3499 27.0408";
		//vol.readUV2(path, file, options);

		globalOptions[VolumeOptions::Config::NameEncodeRange] = VolumeEncoder::EncodeRangeToString(VolumeEncoder::EncodeRangeWind);
		globalOptions[VolumeOptions::Config::NameClipRange] = "100 0 160 40";
		VolumeOptions options(globalOptions);
		vol.readUV(path, file, options);
	}
#endif

#if 1
	String path = "I:/Project/2024/风云/RHU";
	StringVector sv = findFiles(path);
	int i = 0;
	for (auto file : sv)
	{
		//globalOptions[VolumeOptions::Config::NameEncodeRange] = VolumeEncoder::EncodeRangeToString(VolumeEncoder::EncodeRangeWind);
		//globalOptions[VolumeOptions::Config::NameClipRange] = "118.1371 16.6092 129.3499 27.0408";
		//vol.readUV2(path, file, options);

		globalOptions[VolumeOptions::Config::NameEncodeRange] = VolumeEncoder::EncodeRangeToString(VolumeEncoder::EncodeRangePercent);
		//globalOptions[VolumeOptions::Config::NameClipRange] = "100 0 160 40";
		globalOptions[VolumeOptions::Config::NameClipRange] = "118.1371 16.6092 129.3499 27.0408";
		VolumeOptions options(globalOptions);
		vol.readOne(path, file, options);
	}
#endif
}